<script setup>
import { ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { themeOverrides } from '@/naiveUI/index'
import { zhCN, dateZhCN, darkTheme } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import content from './views/content.vue'

import mitt from '@/mitt/index'

const route = useRoute()
const router = useRouter()
const { locale } = useI18n()

let i_locale = ref(null)
let dateLocale = ref(null)
const theme = ref(null)

// 语言修改
mitt.on('changeLanguage', (lang) => {
  lang == 'en' ? (i_locale.value = null) : (i_locale.value = zhCN)
  lang == 'en' ? (dateLocale.value = null) : (dateLocale.value = dateZhCN)
  lang == 'en' ? (locale.value = 'en') : (locale.value = 'zh')
})

mitt.on('changeTheme', (type) => {
  type == 'light' ? (theme.value = null) : (theme.value = darkTheme)
})
</script>

<template>
  <n-config-provider
    preflight-style-disabled
    :theme-overrides="themeOverrides"
    :theme="theme"
    :locale="i_locale"
    :date-locale="dateLocale"
  >
    <n-loading-bar-provider>
      <n-notification-provider>
        <n-message-provider> <content></content></n-message-provider>
      </n-notification-provider>
    </n-loading-bar-provider>
  </n-config-provider>
</template>

<style></style>
